package com.lyy.photovoltaic.common.vo;


import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "ResultVO对象",description = "封装接口返回给前端的数据")
public class ResultVO {
    //响应给前端的状态码
    @ApiModelProperty(value = "响应状态码",dataType = "int")
    private int code;

    //相应给前端的提示信息
    @ApiModelProperty(value = "响应提示信息",dataType = "string")
    private String msg;

    //响应给前端的数据
    @ApiModelProperty(value = "响应数据",dataType = "string")
    private Object data;


    // 默认返回成功状态码，数据对象
    public ResultVO(Object data) {
        this.code = ResultCode.SUCCESS.getCode();
        this.msg = ResultCode.SUCCESS.getMsg();
        this.data = data;
    }


    // 返回指定状态码，数据对象
    public ResultVO(StatusCode statusCode, Object data) {
        this.code = statusCode.getCode();
        this.msg = statusCode.getMsg();
        this.data = data;
    }

    // 只返回状态码
    public ResultVO(StatusCode statusCode) {
        this.code = statusCode.getCode();
        this.msg = statusCode.getMsg();
        this.data = null;
    }

    public ResultVO(StatusCode statusCode, String msg, Object data) {
        this.code =statusCode.getCode();
        this.msg = msg;
        this.data = data;
    }
}

